/*动态改变根元素字体大小*/
console.log("页面进入时间",new Date().getTime())
function recalc() {
	var clientWidth = document.documentElement.clientWidth;
	//	console.log(clientWidth);
	if(!clientWidth) return;
	clientWidth = clientWidth > 420 ? 420 : clientWidth;
	clientWidth = IsPC() ? clientWidth - 20 : clientWidth;
	var rootSize = 40 * (clientWidth / 750);
	var rootSize = Math.round(rootSize);
	document.documentElement.style.cssText += "font-size:" + (rootSize) + 'px!important';
	if(document.body) {
		document.body.style.height = window.innerHeight + "px";
	}
}

function initRecalc() {
	recalc();
	var resizeEvt = 'osrientationchange' in window ? 'orientationchange' : 'resize';
	if(!document.addEventListener) return;
	window.addEventListener(resizeEvt, recalc, false);
	document.addEventListener('DOMContentLoaded', recalc, false);
}

initRecalc();

//动态跳转字体为整数
//try {
	$(function() {
		console.log(new Date().getTime());
		var oriFontSize = [];
		//文字元素
		var textEles = $("body *:not(img,br,hr,ul,dl,script,style,link)").filter(function() {
				var isOk = false;
				if($(this).hasClass("count")){return false};
				$(this).contents().each(function(index,val){
					if(!isOk&&val.nodeType==3&&(/[\w\u4e00-\u9fa5]+/g).test(val.textContent)){
						isOk = true;//只要有文字文本就改变当前标签的font-size为整数
					}
				})
				return isOk;
		})
		//为了防止子元素继承字体大小，必须要先存在一个数组里
		textEles.each(function() {
			oriFontSize.push($(this).css("fontSize"));
		})
		textEles.each(function(index) {
			$(this).css("fontSize", parseInt(oriFontSize[index]));

		})
		console.log(new Date().getTime());
	})

//} catch(e) {
//	console.log(e)
//}

//给头部增加自己的点击效果
$(function(){
	$(".backHeader .cephalo .img_jiantou,.Pending_Header .backArr,header .menuIcon").on("click",function(e){
		var targetW = $(this).width();
		var targetH = $(this).height();
		scaleR = Math.max(targetW - e.offsetX, e.offsetX, targetH - e.offsetY, e.offsetY);
		var temDiv = $("<div class='ani_' />");
		temDiv.appendTo($(this))
//		alert(e.offsetX)
		window.getComputedStyle(temDiv[0]).width;
		temDiv.css({
			top: e.offsetY,
			left: e.offsetX,
			transform:"scale("+scaleR*2+")",
			opacity:0
		})
		temDiv.one("transitionend",function(){
			$(this).remove();
		})
	})
})



document.addEventListener("DOMContentLoaded", function() {
	document.body.style.height = window.innerHeight + "px";
	new Ripple({
		opacity: .5, //水波纹透明度
		speed: .3, //水波纹扩散速度
		bgColor: "#f19272", //水波纹颜色
		cursor: true //是否显示手型指针
	})
}, false);
//是否为pc端   
function IsPC() {
	var userAgentInfo = navigator.userAgent;
	var Agents = ["Android", "iPhone",
		"SymbianOS", "Windows Phone",
		"iPad", "iPod"
	];
	var flag = true;
	for(var v = 0; v < Agents.length; v++) {
		if(userAgentInfo.indexOf(Agents[v]) > 0) {
			flag = false;
			break;
		}
	}
	return flag;
}

//水纹代码
! function(t, e) {
	if(void 0 === n || !n) {
		var n = function(t) {
			var e = {
				opacity: .5,
				speed: .6,
				bgColor: "#ffffff",
				cursor: !0
			};
			this.option = this.extend(t, e), this.isltIE9() || this.init()
		}
	}
	n.prototype = {
		createEle: function(t) {
			return e.createElement(t)
		},
		extend: function(t, e) {
			var n = JSON.parse(JSON.stringify(e));
			for(var i in t) {
				n[i] = t[i]
			}
			return n
		},
		isltIE9: function() {
			return !!/MSIE6.0|MSIE7.0|MSIE8.0|MSIE9.0/i.test(navigator.userAgent.split(";")[1].replace(/[ ]/g, ""))
		},
		getPosition: function(t) {
			var e = this.getBoundingClientRect(),
				n = Math.max(e.width, e.height);
			return {
				range: n,
				x: t.clientX - e.left - n / 2,
				y: t.clientY - e.top - n / 2
			}
		},
		loadCss: function() {
			var t = e.scripts,
				n = t[t.length - 1].src,
				i = n.substring(0, n.lastIndexOf("/") + 1);
			e.head.appendChild(function() {
				var t = e.createElement("link");
				return t.href = i + "need/ripple.css", t.type = "text/css", t.rel = "styleSheet", t.id = "ripplecss", t
			}())
		},
		addEvent: function() {
			for(var t = this, n = 0; n < this.elements.length; n += 1) {
				"boolean" == typeof t.option.cursor && t.option.cursor && (this.elements[n].style.cursor = "pointer"), this.elements[n].addEventListener("mousedown", function(n) {
					n.stopPropagation();
					var i = t.getPosition.call(this, n),
						o = e.createElement("span");
					o.className = "ripple", o.style.top = i.y + "px", o.style.left = i.x + "px", o.style.width = i.range + "px", o.style.height = i.range + "px", o.style.animationDuration = t.option.speed + "s", o.style.background = t.option.bgColor, o.style.opacity = t.option.opacity, o.addEventListener("animationend", function() {
						this.parentNode.removeChild(this)
					}, !1), this.appendChild(o)
				}, !1)
			}
		}
	}, n.prototype.init = function() {
		var n = this;
		t.onload = function() {
			n.elements = e.querySelectorAll('[data-ripple="ripple"]'), n.addEvent()
		}
	}, t.Ripple = n
}(window, document);